from flask import render_template
from datetime import datetime

class WebRoutes:
    def __init__(self, app, joystick_manager):
        self.app = app
        self.joystick_manager = joystick_manager
        
        # 注册Web路由
        self.register_routes()
    
    def register_routes(self):
        self.app.route('/')(self.index)
        self.app.route('/joystick/view')(self.view_joystick_data)
    
    def index(self):
        """主页"""
        return render_template('index.html')
    
    def view_joystick_data(self):
        """查看所有手柄数据页面"""
        joystick_data = self.joystick_manager.get_all_data()
        return render_template('joystick_data.html', joystick_data=joystick_data)
